<?php
/**
 * Created by PhpStorm.
 * User: tandunzhao
 * Date: 2018/5/30
 * Time: 下午1:42
 */

namespace App\Modules\Pay\Models;


use Illuminate\Database\Eloquent\Model;

class PayWithdrawCash extends Model
{
    protected $table = 'pay_withdraw_cashes';
    protected $fillable = ['uid', 'amount', 'tallage', 'status', 'remark', 'payment_remark', 'serial_number', 'check_user_id'];




    /**
     * 提现列表
     * @param $params[]
     *                  uid:用户ID 可选
     *                  start_time:开始时间 可选
     *                  end_time:结束时间 可选
     *                  status: 状态数组
     * @param $isAll
     * @return mixed
     */
    public static function getList($params=[], $isAll = '') {
        $sqlObj = self::orderBy('created_at','desc');

        if(isset($params['uid']) && $params['uid']) {
            $sqlObj->where('uid','>=', $params['uid']);
        }

        if(isset($params['start_time']) && $params['start_time']) {
            $sqlObj->where('created_at','>=', $params['start_time']);
        }
        if(isset($params['end_time']) && $params['end_time']) {
            $sqlObj->where('created_at','<=', $params['end_time']);
        }

        if(isset($params['status']) && $params['status']) {
            $sqlObj->whereIn('status', $params['status']);
        }

        if($isAll) {
            return $sqlObj->get();
        } else {
            return $sqlObj->paginate();
        }
    }
}